package com.guoqing.jdbcUtil;

import java.sql.Connection;
import java.sql.DriverManager;

public class Util {
   private static	Connection conn;
   /**
    * 获得链接
    * @return
    */
	public static Connection getConnection() {
		  try {
		   Class.forName("com.mysql.jdbc.Driver");
		   conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/cook?characterEncoding=utf-8", "root", "zgq");
		   return conn;
		  } catch (Exception e) {
		   e.printStackTrace();
		   return null;
		  }
		 }
	
	/**
	 * 关闭链接
	 */
	public static void close()
	{
		try {
			if(null != conn)
			{
				conn.close();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
